<!doctype html>



  


<html class="theme-next mist use-motion" lang="zh-Hans">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>









<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />



  <meta name="google-site-verification" content="VvyjvVXcJQa0QklHipu6pwm2PJGnnchIqX7s5JbbT_0" />













  
  
  <link href="/wangrunchao/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />




  
  
  
  

  
    
    
  

  

  

  

  

  
    
    
    <link href="//fonts.googleapis.com/css?family=Lato:300,300italic,400,400italic,700,700italic&subset=latin,latin-ext" rel="stylesheet" type="text/css">
  






<link href="/wangrunchao/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/wangrunchao/css/main.css?v=5.1.1" rel="stylesheet" type="text/css" />


  <meta name="keywords" content="Hexo, NexT" />








  <link rel="shortcut icon" type="image/x-icon" href="/wangrunchao/favicon.ico?v=5.1.1" />






<meta name="description" content="Hexo 在Hexo官网上如此描述：Hexo is a fast, simple and powerful blog framework. You write posts in Markdown (or other languages) and Hexo generates static files with a beautiful theme in seconds.（Hexo是一个快速，简单和强">
<meta property="og:type" content="article">
<meta property="og:title" content="Hexo">
<meta property="og:url" content="http://wangruchao.oschina.io/wangrunchao/2017/07/04/Hexo/index.html">
<meta property="og:site_name" content="WRC网站">
<meta property="og:description" content="Hexo 在Hexo官网上如此描述：Hexo is a fast, simple and powerful blog framework. You write posts in Markdown (or other languages) and Hexo generates static files with a beautiful theme in seconds.（Hexo是一个快速，简单和强">
<meta property="og:updated_time" content="2017-07-04T09:37:47.659Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="Hexo">
<meta name="twitter:description" content="Hexo 在Hexo官网上如此描述：Hexo is a fast, simple and powerful blog framework. You write posts in Markdown (or other languages) and Hexo generates static files with a beautiful theme in seconds.（Hexo是一个快速，简单和强">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/wangrunchao/',
    scheme: 'Mist',
    sidebar: {"position":"left","display":"post","offset":12,"offset_float":0,"b2t":false,"scrollpercent":false},
    fancybox: true,
    motion: true,
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="http://wangruchao.oschina.io/wangrunchao/2017/07/04/Hexo/"/>





  <title>Hexo | WRC网站</title>
  





  <script type="text/javascript">
    var _hmt = _hmt || [];
    (function() {
      var hm = document.createElement("script");
      hm.src = "https://hm.baidu.com/hm.js?50c15455e37f70aea674ff4a663eef27";
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(hm, s);
    })();
  </script>










</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  
  
    
  

  <div class="container sidebar-position-left page-post-detail ">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/wangrunchao/"  class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">WRC网站</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle">WRC网站</p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/wangrunchao/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/wangrunchao/archives" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
            
            归档
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/wangrunchao/tags" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />
            
            标签
          </a>
        </li>
      

      
    </ul>
  

  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">
    <link itemprop="mainEntityOfPage" href="http://wangruchao.oschina.io/wangrunchao/wangrunchao/2017/07/04/Hexo/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="WRC">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="http://img0.imgtn.bdimg.com/it/u=2531384262,3699915741&fm=214&gp=0.jpg">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="WRC网站">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">Hexo</h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2017-07-04T17:25:54+08:00">
                2017-07-04
              </time>
            

            

            
          </span>

          

          
            
              <span class="post-comments-count">
                <span class="post-meta-divider">|</span>
                <span class="post-meta-item-icon">
                  <i class="fa fa-comment-o"></i>
                </span>
                <a href="/wangrunchao/2017/07/04/Hexo/#comments" itemprop="discussionUrl">
                  <span class="post-comments-count ds-thread-count" data-thread-key="2017/07/04/Hexo/" itemprop="commentCount"></span>
                </a>
              </span>
            
          

          
          

          

          

          

        </div>
      </header>
    

    <div class="post-body" itemprop="articleBody">

      
      

      
        <h2 id="Hexo"><a href="#Hexo" class="headerlink" title="Hexo"></a>Hexo</h2><blockquote>
<p>在Hexo官网上如此描述：Hexo is a fast, simple and powerful blog framework. You write posts in Markdown (or other languages) and Hexo generates static files with a beautiful theme in seconds.（Hexo是一个快速，简单和强大的博客框架。你可以使用Markdown（或其他语言）写博客，之后Hexo能在几秒钟生成具有美观主题的静态文件。）如果你想了解更多关于Hexo的东西，请移步 Hexo官网 。<br>Hexo是一款基于Node.js的静态博客框架，可以deploy到Github上，所以首先要在电脑上安装git和node.js,并在Github上注册自己的账号，由于这些东西不是本篇博客要涉及到的主要内容，你可以谷歌、百度，也可以参考我下面提供的链接。</p>
<p>##Git安装<br>你可以去官网下载 Git ，因为国外资源可能很慢，你也可以下载我在网盘上提供的 Git镜像 。具体如何使用，请参照廖雪峰老师关于 Git的教程 ，如果你仅仅是想安装git那看看 Git安装 的那个章节</p>
</blockquote>
<h2 id="Node-js安装配置"><a href="#Node-js安装配置" class="headerlink" title="Node.js安装配置"></a>Node.js安装配置</h2><blockquote>
<p>关于Node.js的安装以及配置，可以参照菜鸟教程上面关于 Node.js 安装配置的教程，上面也有下载的链接，本人就是参照上面安装的。具网上有些文章说，安装完成后最好重启电脑，以免之后无法使用hexo的相关命令，我倒是没有遇到，不过如果大家遇到这种问题就重启吧。</p>
</blockquote>
<h2 id="Hexo安装"><a href="#Hexo安装" class="headerlink" title="Hexo安装"></a>Hexo安装</h2><blockquote>
<p>必须要在你安装了上述的Git以及Node.js之后才能进行Hexo的安装。</p>
</blockquote>
<h3 id="1-用以下命令安装Hexo"><a href="#1-用以下命令安装Hexo" class="headerlink" title="1. 用以下命令安装Hexo"></a>1. 用以下命令安装Hexo</h3><blockquote>
<p>在任意地方点击右键，选择 <strong>Git Bash Here</strong></p>
</blockquote>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">$ npm install -g hexo-cli</div></pre></td></tr></table></figure>
<p>如果安装过程中遇到一下错误：<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">ERROR Deployer not found : github</div></pre></td></tr></table></figure></p>
<p>运行<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">$ npm install hexo-deployer-git --save</div></pre></td></tr></table></figure></p>
<h3 id="2-创建博客"><a href="#2-创建博客" class="headerlink" title="2. 创建博客"></a>2. 创建博客</h3><blockquote>
<p>创建博客存放目录，并进行初始化，安装依赖包（最好不要使用带中文的路径，以免后面出现不必要的麻烦）<br>打开一个目录，在这个地方点击右键选择 Git Bash Here ,执行以下命令<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div></pre></td><td class="code"><pre><div class="line">$ hexo init &lt;folder&gt; #创建目录并执行初始化</div><div class="line">$ cd &lt;folder&gt;</div><div class="line">$ npm install #安装依赖包</div><div class="line">&lt;folder&gt; 改为你想要的目录。</div></pre></td></tr></table></figure></p>
<p>当然你也可以自己新建一个目录，比如我在F盘中创建了myblog目录，进入目录中点击右键选择 Git Bash Here ，直接执行以下命令<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line">$ hexo init </div><div class="line">$ npm install</div></pre></td></tr></table></figure></p>
<p>不管你用哪种方式，执行完毕后你会发现以下目录结构<br> .<br>├── _config.yml<br>├── package.json<br>├── scaffolds<br>├── source<br>│     ├── _drafts<br>│     └── _posts<br>└── themes</p>
</blockquote>
<h4 id="3-启动服务"><a href="#3-启动服务" class="headerlink" title="3. 启动服务"></a>3. 启动服务</h4><blockquote>
<p>执行以下命令来启动服务<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line">$ hexo g #hexo generate，生成静态文件</div><div class="line">$ hexo s #hexo server，启动本地服务器</div></pre></td></tr></table></figure></p>
<p>如果启动过程中没有报错，此时你用浏览器访问 <a href="http://localhost:4000/" target="_blank" rel="external">http://localhost:4000/</a> ，是不是看到了一个Hello World的博客页面，hexo3.0使用的默认主题是landscape（之后我会讲如何更换主题，以及集成第三方的工具），而且此时的服务是本地启动的，别人并不能看到（继续我接下来的操作就好了）。</p>
<p>这个时候如果在浏览器没看到漂亮的博客页面怎么办，别急，先确认你在启动过程中是不是报错了，如过有的话估计是上面的操作有误，如果没有并且发现页面一直在加载中，估计是端口被占用了，我就遇到了这个问题。怎么办?把4000端口给杀死，还有更简单的——在 hexo s 命令后面加上启动参数，修改默认端口： hexo s -p <port> ，比如我用的 hexo s -p 8000 ，现在重新访问 <a href="http://localhost:8000/" target="_blank" rel="external">http://localhost:8000/</a> 记得把地址的8000改成你自己对应的端口号，是不是看到了美丽的界面。</port></p>
</blockquote>
<h3 id="4-注册Github账号，并创建仓库。"><a href="#4-注册Github账号，并创建仓库。" class="headerlink" title="4. 注册Github账号，并创建仓库。"></a>4. 注册Github账号，并创建仓库。</h3><blockquote>
<p>想要别人也访问到你的页面，跟着继续吧。首先在 Github 官网上注册一个账号，有账号的跳过注册，直接登录。登录后找到 new repository 按钮创建一个新的仓库。</p>
<p>然后填写repository name就行了，要注意的是： 这个名字的格式必须为 youname.github.io ，并且必须和你的账户名相同，比如我的账户名是BrightLoong，我的地址就是brightloong.github.io （最开始我就是将name随意填写，虽然是这个格式但是根本访问不了，会报404的错误）。</p>
</blockquote>
<h3 id="5-将本地文件推送到github"><a href="#5-将本地文件推送到github" class="headerlink" title="5. 将本地文件推送到github"></a>5. 将本地文件推送到github</h3><blockquote>
<p>最后，剩下的就是将本地文件推送到github上了，首先打开站点配置文件 _config.yml ，比如我的路径是：F:\myblog_bonfig.yml。找到最后的 deploy 属性，如果没有就自己添加，将配置修改为：</p>
</blockquote>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div></pre></td><td class="code"><pre><div class="line">deploy:</div><div class="line">  type: git #推送方式</div><div class="line">  repository: https://github.com/BrightLoong/BrightLoong.github.io.git #你的推送地址</div><div class="line">  branch: master #你要推送的分支</div></pre></td></tr></table></figure>
<blockquote>
<p>这个地方要注意的是属性后面的冒号必须要有一个空格，否则会报错<br>配置好之后使用以下命令将服务部署到github上。</p>
</blockquote>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line">$ hexo clean</div><div class="line">$ hexo g</div><div class="line">$ hexo d</div></pre></td></tr></table></figure>
<blockquote>
<p>使用 hexo d 命令，第一次会要求你输入用户名和密码，用户名和密码就是你注册github时候使用的用户名和密码。如果遇到以下错误：</p>
</blockquote>
<p>ERROR Deployer not found : github<br>运行<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">$ npm install hexo-deployer-git --save</div></pre></td></tr></table></figure></p>
<p>再执行上面的命令。<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">$ npm install hexo-deployer-git --save</div></pre></td></tr></table></figure></p>
<p>如果成功会有以下提示（我的账户名叫wangruchao）</p>
<p>如果没有报错误，那么博客就已经搭建起来，并发布到Github上了，在浏览器输入 youname.github.io 就能看到自己的博客了，如果中途报错说未识别的用户名，那么如果你确定你填写是正确的，重复使用 hexo d 命令，我当时就遇到过这种情况，我估计是网络不好引起的。</p>

      
    </div>

    <div>
      
        

      
    </div>

    <div>
      
        

      
    </div>

    <div>
      
        

      
    </div>

    <footer class="post-footer">
      

      
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/wangrunchao/2017/07/04/hello-world/" rel="next" title="Hello World王儒超">
                <i class="fa fa-chevron-left"></i> Hello World王儒超
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
          </div>
        </div>
      

      
      
    </footer>
  </article>



    <div class="post-spread">
      
    </div>
  </div>


          </div>
          


          
  <div class="comments" id="comments">
    
      <div class="ds-thread" data-thread-key="2017/07/04/Hexo/"
           data-title="Hexo" data-url="http://wangruchao.oschina.io/wangrunchao/2017/07/04/Hexo/">
      </div>
    
  </div>


        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap" >
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
          <img class="site-author-image" itemprop="image"
               src="http://img0.imgtn.bdimg.com/it/u=2531384262,3699915741&fm=214&gp=0.jpg"
               alt="WRC" />
          <p class="site-author-name" itemprop="name">WRC</p>
           
              <p class="site-description motion-element" itemprop="description">WRC网站</p>
          
        </div>
        <nav class="site-state motion-element">

          
            <div class="site-state-item site-state-posts">
              <a href="/wangrunchao/archives">
                <span class="site-state-item-count">2</span>
                <span class="site-state-item-name">日志</span>
              </a>
            </div>
          

          

          

        </nav>

        

        <div class="links-of-author motion-element">
          
            
              <span class="links-of-author-item">
                <a href="https://github.com/wangruchao/" target="_blank" title="GitHub">
                  
                    <i class="fa fa-fw fa-github"></i>
                  
                  GitHub
                </a>
              </span>
            
          
        </div>

        
        
          <div class="cc-license motion-element" itemprop="license">
            <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" class="cc-opacity" target="_blank">
              <img src="/wangrunchao/images/cc-by-nc-sa.svg" alt="Creative Commons" />
            </a>
          </div>
        

        
        

        


      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#Hexo"><span class="nav-number">1.</span> <span class="nav-text">Hexo</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#Node-js安装配置"><span class="nav-number">2.</span> <span class="nav-text">Node.js安装配置</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#Hexo安装"><span class="nav-number">3.</span> <span class="nav-text">Hexo安装</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#1-用以下命令安装Hexo"><span class="nav-number">3.1.</span> <span class="nav-text">1. 用以下命令安装Hexo</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#2-创建博客"><span class="nav-number">3.2.</span> <span class="nav-text">2. 创建博客</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#3-启动服务"><span class="nav-number">3.2.1.</span> <span class="nav-text">3. 启动服务</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#4-注册Github账号，并创建仓库。"><span class="nav-number">3.3.</span> <span class="nav-text">4. 注册Github账号，并创建仓库。</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#5-将本地文件推送到github"><span class="nav-number">3.4.</span> <span class="nav-text">5. 将本地文件推送到github</span></a></li></ol></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright" >
  
  &copy;  2011 - 
  <span itemprop="copyrightYear">2017</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">WRC</span>
</div>


<div class="powered-by">
  由 <a class="theme-link" href="https://hexo.io">Hexo</a> 强力驱动
</div>

<div class="theme-info">
  主题 -
  <a class="theme-link" href="https://github.com/iissnan/hexo-theme-next">
    NexT.Mist
  </a>
</div>


        

        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  












  
  <script type="text/javascript" src="/wangrunchao/lib/jquery/index.js?v=2.1.3"></script>

  
  <script type="text/javascript" src="/wangrunchao/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>

  
  <script type="text/javascript" src="/wangrunchao/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>

  
  <script type="text/javascript" src="/wangrunchao/lib/velocity/velocity.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/wangrunchao/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/wangrunchao/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>


  


  <script type="text/javascript" src="/wangrunchao/js/src/utils.js?v=5.1.1"></script>

  <script type="text/javascript" src="/wangrunchao/js/src/motion.js?v=5.1.1"></script>



  
  

  
  <script type="text/javascript" src="/wangrunchao/js/src/scrollspy.js?v=5.1.1"></script>
<script type="text/javascript" src="/wangrunchao/js/src/post-details.js?v=5.1.1"></script>



  


  <script type="text/javascript" src="/wangrunchao/js/src/bootstrap.js?v=5.1.1"></script>



  

  
    
  

  <script type="text/javascript">
    var duoshuoQuery = {short_name:"notes-iissnan"};
    (function() {
      var ds = document.createElement('script');
      ds.type = 'text/javascript';ds.async = true;
      ds.id = 'duoshuo-script';
      ds.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') + '//static.duoshuo.com/embed.js';
      ds.charset = 'UTF-8';
      (document.getElementsByTagName('head')[0]
      || document.getElementsByTagName('body')[0]).appendChild(ds);
    })();
  </script>

  
    
    
    <script src="/wangrunchao/lib/ua-parser-js/dist/ua-parser.min.js?v=0.7.9"></script>
    <script src="/wangrunchao/js/src/hook-duoshuo.js"></script>
  
















  





  

  

  

  

  

  

</body>
</html>
